<?php

//1，判断用户是否新用户
//2，发送今日推荐的节目
//3，获取此用户是否有未读的消息
//4, 发送分类推荐内容


	header('Content-type: text/html; charset=utf-8');
	if(!isset($_SESSION)){
		session_start();
	}

	$pdo = null;
	try {
	    $pdo = new PDO('sqlite:mydb1.db');
	    $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
	} catch (PDOException $e) {
	    die("连接失败: " . $e->getMessage());
	}

	if(isset($_GET['userId'])){
		$userId = $_GET['userId'];
		$sql1 = "SELECT * FROM users WHERE uId = '$userId'";
		$stmt = $pdo->query($sql1);
		$result = $stmt->fetchAll(PDO::FETCH_ASSOC);
		if(count($result) > 0){}else{ 
			$sql2 = "INSERT INTO users (name, uId, level,souc,dingy) VALUES(?, ?, ?, ?, ?)";
			$stmt = $pdo->prepare($sql2);
			$stmt->execute(['未命名', $userId, 0, 0, 0]); 
		}
		echo json_encode($result);
		return;
	}


?>